<?php
define("PS_PATH",dirname(__FILE__));
require PS_PATH.'/core/preAction.php';

define('AUTH_PASSWD','xinzhong');
if(!isset($_GET['auth']) || AUTH_PASSWD != $_GET['auth']){
	echo 'Auth failed!';
	exit();
}

if(isset($_GET['reset'])){
	$reset = true;
}else{
	$reset = false;
}


import('model.user.class.php');
import('model.channel.class.php');
import('model.message.class.php');
import('model.request.class.php');
import('model.session.class.php');

if($reset){
	log_i("Droping all tables...");
	ModelMessage::dropTable();
	ModelSession::dropTable();
	ModelRequest::dropTable();
	ModelUser::dropTable();
	ModelChannel::dropTable();
	log_i("All tables are droped.");
}

log_i("Creating all tables...");
ModelChannel::createTable();
ModelUser::createTable();
ModelRequest::createTable();
ModelSession::createTable();
ModelMessage::createTable();
log_i("All tables are created.");
